package gui;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.JTable;
import javax.swing.JScrollPane;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class ReportarNotas extends JFrame {

	private JPanel contentPane;
	private JTable table;
	private JScrollPane scrollPane;
	private JButton btnNewButton;
	private JButton btnGuardarNotas;

	/**
	 * Launch the application.
	 */
	/*public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ReportarNotas frame = new ReportarNotas();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public ReportarNotas(NotasYExamenes padreNotasYExamenes) {
		addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e){
				padreNotasYExamenes.nullReportarNotas();
			}
		});		
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		setBounds(100, 100, 311, 482);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		this.setTitle("Reportar notas");
		
		
		JLabel lblCurso = new JLabel("");
		lblCurso.setBounds(10, 11, 274, 14);
		contentPane.add(lblCurso);
		lblCurso.setText("Curso: " + padreNotasYExamenes.getCurrentCursada().getCurso().getNombre());
		
		JLabel lblCodigoCursada = new JLabel("");
		lblCodigoCursada.setBounds(10, 36, 274, 14);
		contentPane.add(lblCodigoCursada);
		lblCodigoCursada.setText("Comision: " + padreNotasYExamenes.getCurrentCursada().getCodigo());
		
		JLabel lblInstanciaDeEvaluacin = new JLabel("Instancia de evaluacion");
		lblInstanciaDeEvaluacin.setBounds(10, 61, 125, 14);
		contentPane.add(lblInstanciaDeEvaluacin);
		
		JComboBox comboBox = new JComboBox();
		comboBox.setBounds(145, 58, 139, 20);
		contentPane.add(comboBox);
		
		scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 104, 274, 293);
		contentPane.add(scrollPane);
		
		table = new JTable(){
			@Override
			public boolean isCellEditable(int row, int colum)
			{
				if(colum==0)
					return false;
				else return true;
			}
		};
		
		scrollPane.setViewportView(table);
		
		DefaultTableModel model = new DefaultTableModel();
		Object[] encabezado = {"Alumno", "Nota"};
		model.setColumnIdentifiers(encabezado);
		table.setModel(model);
		
		//model.setRowCount(3);
		
		//model.setValueAt("pepe", 0, 0);
		
		btnNewButton = new JButton("Cancelar");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				padreNotasYExamenes.nullReportarNotas();
				dispose();
				
			}
		});
		
		btnNewButton.setBounds(183, 410, 101, 23);
		contentPane.add(btnNewButton);
		
		btnGuardarNotas = new JButton("Guardar notas");
		btnGuardarNotas.setBounds(72, 410, 101, 23);
		contentPane.add(btnGuardarNotas);
	}
}
